home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 3_0 / APPFILET / APPFILET.C next >
C/C++ Source or Header  |  1989-04-14  |  2KB  |  58 lines

  1. /*
  2.  Simple Think C program to report what files we've been asked to open.
  3.  When you start up a Macintosh program by opening a document or printing
  4.  a document, or by selecting both the application and the document, the
  5.  application gets this information passed to it.
  6.  
  7.  To try this code, In Think C, create a project with this file, MacTraps,
  8.  and Stdio.
  9.  In MPW 3.0, issue the following commands:
  10.      c aft.c
  11.     link {CLibraries}CRunTime.o {CLibraries}StdCLib.o ╢
  12.     {CLibraries}CInterface.o {Libraries}Interface.o aft.c.o -o aft   
  13.  
  14.  Set the program creator to be some arbitrary four character type (I used
  15.  'FooB'.  Create some files, and change their creator to 'FooB' using
  16.  ResEdit or your favorite file manipulator.  Double click on the text
  17.  file, or select the file and choose "Print" from the Finder File menu.
  18. */
  19.  
  20.  
  21. #ifdef macintosh    /* MPW */
  22. #include "SegLoad.h"
  23. #endif
  24. #ifdef THINK_C
  25. #include "SegmentLdr.h"
  26. #endif
  27.  
  28. /* procedure prototypes. */
  29. void     main(void);
  30. void    ShowAppFiles(short);
  31. int        printf(char *, ...);
  32.  
  33. void
  34. main()
  35. {
  36.     short    message;    /* whether to open or print the files */
  37.     short    count;        /* how many files to open or print */
  38.     AppFile    app;        /* structure holding vRefNum, fType, version, pascal name */
  39.     short    i;
  40.  
  41.     CountAppFiles(&message, &count);
  42.     if (count > 0)
  43.     {
  44.         if (message == appOpen)
  45.             printf("We were asked to open these files:\n");
  46.         else if (message == appPrint)
  47.             printf("We were asked to print these files:\n");
  48.         for (i = 1; i <= count; i++ )
  49.         {
  50.             GetAppFiles(i, &app);
  51.             printf("app.fName[%d] = %P\n", i, app.fName);
  52.         }
  53.     }
  54.     else
  55.         printf("we weren't asked to do anything.\n");
  56. }
  57.  
  58.